#!/usr/bin/python
# -*- coding: UTF-8 -*-
import pandas as pd
import tushare as ts
# str
pd.set_option('display.width', 5000)

def editCode(code):
    if code.startswith("6"):
        return "sh"+code;
    else:
        return "sz"+code;

all=ts.get_stock_basics()
new=pd.DataFrame(all,columns=["name"])
new["symbol"]=new.index
new["symbol"]=new["symbol"].apply(editCode)
values=new.values
result=dict(values)
with open("stock_zn.json","w",encoding="utf-8") as f:
    f.write(str(result))
print(result)



